<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!--
    	作者：845510257@qq.com
    	时间：2017-10-25
    	描述：title部分，公共js,公共css和jstl标签库
    -->
<%@include file="/source/page/parts/title.jsp"%>
<!-- 	下面引入本页面单独引入的资源 -->
<link rel="stylesheet" href="/GDZjiajiaowang/source/css/studentInfo.css"
	type="text/css" />
<link rel="stylesheet" href="/GDZjiajiaowang/source/css/indexStyle.css"
	type="text/css" />
<link rel="stylesheet"
	href="/GDZjiajiaowang/source/css/teacherOrder.css" type="text/css" />

<script type="text/javascript">
	$(function() {

		//el表达式实现主页点击明星学员跳转studentInfo页面
		$(".student_introduce_banner_name").text("${studentInfos.studentName}");
		$(".student_introduce_banner_experience").text(
				"${studentInfos.studentPhone}");
		$("#student_problem").text("${studentInfos.studentDesc}");
		$("#student_stutype").text("${studentInfos.gradeName}");
		$("#student_sex").text("${studentInfos.studentSex}");
		$("#student_viptime").text("${studentInfos.studentDate}");
		$(".student_introduce_banner_num").text("${studentInfos.studentId}");
		$("#student_photo").attr("src", "${studentInfos.src}");
		$("#other_asks").text("${studentInfos.other}");
		$("#student_grade").text("${studentInfos.gradeName}");
		$("#teaching_methid").text("${studentInfos.workType}");
		$("#total_kinds").text("${studentInfos.addressDesc}");
		$("#where_kinds").text("${studentInfos.addressName}");
		$("#subject_kinds").text("${studentInfos.subjectName}");

		var studentIdjson = {
			"studentId" : "${studentInfos.studentId}"
		};
		$.ajax({
			type : "post",
			data : studentIdjson,
			dataType : "json",
			url : "/GDZjiajiaowang/StudentInfoOrderServlet",
			contentType : "application/x-www-form-urlencoded; charset =utf-8",
			success : function(orders) {
				if (null == orders || orders.length == 0) {
					return false;
				}
				var str = "";
				for (var i = 0; i < orders.length; i++) {
					var order = orders[i];
					var status = "成功";
					if (order.profit == 0) {
						status = "失败";
					}
					var orderId = "d" + order.orderId;
					str += "<tr><td>" + orderId + "</td><td>"
							+ order.teacherRealName + "</td><td>" + status
							+ "</td><td>" + order.orderFinishTime
							+ "</td></tr>";
				}
				$("#orders tr:gt(0)").remove();
				$("#orders").append(str);
			}
		})
	})
</script>
</head>
<body>
	<!--
            	作者：GGVVR
            	时间：2017-10-25
            	描述：header部分（head_top、head_middle、head_botton）
            -->
	<%@include file="/source/page/parts/header.jsp"%>

	<section>
		<div class="main_line">

			<div class="main_line_one">
				<p>
					<span>GDZ家教网</span> <span>></span> <span>学生信息列表</span> <span>></span>
					<span>学生个人信息</span>
				</p>
			</div>

		</div>
		<div class="student_introduce_line_one">
			<div class="student_introduce_banner">
				<div class="student_introduce_banner_center">
					<div class="student_introduce_banner_center_line01">
						<div class="student_introduce_banner_center_line01_photo">
							<img src="/GDZjiajiaowang/source/img/11.png" id="student_photo" />
						</div>
						<div>
							<p>
								<span class="student_introduce_banner_name">吴金山</span><span
									id="name_inputin">（学员）</span><span>编号:</span><span
									class="student_introduce_banner_num">1231</span>
							</p>
							<p>学员需求：</p>
							<p class="student_introduce_banner_introduc">
								学员主要情况：<b id="student_problem">英语弱</b>，需要找到一名教学经验丰富,认证负责的优秀教师，最好为<b
									id="teacher_require">高校大学生。</b>
							</p>
<!-- 							<p> -->
<!-- 								联系方式:<b class="student_introduce_banner_experience">13913944983</b> -->
<!-- 							</p> -->
						</div>

					</div>
					<div class="student_introduce_banner_center_line02">
						<div class="student_introduce_banner_center_line02_center">
							<ul>
								<li>学生类型：<span><b id="student_stutype">高一</b> 学员</span></li>
								<li>性别：<span id="student_sex">男</span></li>

								<li>GDZ求教年龄：<span id="student_viptime">2017-06-12</span></li>
							</ul>
						</div>
					</div>
					<div class="student_introduce_banner_center_line03">
						<div class="student_introduce_banner_center_right_1">
							<p>
								留下联系方式？<span>李传瑞</span>老师？
							</p>
							<form>
								<div class="order_person">
									<label id="phoneLabel">*联系方式<br> <input type="text"
										name="userPhone" value="" id="login_phone" /><br /></label> <label id="pwdLabel">*用户密码<br />
										<input type="password" name="userName" value=""
										/ id="login_pwd"><br /></label> <label id="subjectLabel">*科目
										<div class="chose_subject_div clearfix" id="chose_subject_div">
											<span class="chose_subject" subjectId="1">语文</span> <span
												class="chose_subject" subjectId="2">数学</span> <span
												class="chose_subject" subjectId="3">英语</span> <span
												class="chose_subject" subjectId="4">物理</span> <span
												class="chose_subject" subjectId="5">化学</span> <span
												class="chose_subject" subjectId="7">地理</span> <span
												class="chose_subject" subjectId="8">政治</span> <span
												class="chose_subject" subjectId="9">历史</span> <span
												subjectId="6" class="chose_subject">生物</span>

										</div>

									</label> <input type="button" name="" value="提交查找"
										id="order_person_submit" />
								</div>

							</form>




						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="student_introduce_line_two">
			<div class="student_introduce_line_two_left">
				<div class="student_introduce_line_two_left_line01 clearfix">
					<ul class="clearfix">
						<li>详细信息</li>
						<li>曾经订单</li>
						<li>学生学籍</li>
						<li>学员联系方式</li>
					</ul>
				</div>
				<div class="student_info">
					<h1>详细信息</h1>
					<table border="" cellspacing="" cellpadding="">
						<tr>
							<td>补习科目：</td>
							<td id="subject_kinds">高一全科，高二理科，高三数学</td>
						</tr>
						<tr>
							<td>地区要求：</td>
							<td id="where_kinds">小行路</td>
						</tr>
						<tr>
							<td>具体区域：</td>
							<td id="total_kinds">无要求</td>
						</tr>
						<tr>
							<td>辅导方式：</td>
							<td id="teaching_methid">上门辅导</td>
						</tr>
						<tr>
							<td>学生年级：</td>
							<td><b id="student_grade">高一</b></td>
						</tr>
						<tr>
							<td>其他要求：</td>
							<td id="other_asks">暂无</td>
						</tr>
					</table>
				</div>
				<div class="student_success_orders">
					<h1>曾经订单</h1>
					<table border="" cellspacing="" cellpadding="" id="orders">
						<tr>
							<td>订单号</td>
							<td>教员姓名</td>
							<td>状态</td>
							<td>接单日期</td>
						</tr>
						<tr>
							<td>1101</td>
							<td><b>1212</b>李传瑞</td>
							<td>成功</td>
							<td>2016-12-6</td>
						</tr>
					</table>
				</div>
				<div class="student_education_dream"></div>
				<div class="student_pictures"></div>
			</div>

		</div>







	</section>
	<!--
    	作者：845510257@qq.com
    	时间：2017-10-25
    	描述：footer部分，
    -->
	<%@include file="/source/page/parts/footer.jsp"%>

	<!--
    	作者：杨辉
    	时间：2017-10-25
    	描述：登录弹窗，
    -->
	<%@include file="/source/page/parts/loginMini.jsp"%>


	<!--
    	作者：吴金山
    	时间：2017-10-25
    	描述：登录js
    -->
	<%@include file="/source/page/parts/login.jsp"%>



	<script type="text/javascript">
		$(function() {
			//判断如果是学生的话就隐藏预约
			var type = $.cookie("type");
			if (type == 1) {
				$(".student_introduce_banner_center_line03").hide();
			}

			// 	设置可选科目
			var subjects_divspan = "${studentInfos.subjectName}";
			$("#chose_subject_div span").each(function() {
				if (subjects_divspan.indexOf($(this).text()) >= 0) {
					$(this).show().addClass("canTeachSubject");
				} else {
					$(this).hide();
				}
			})
			$(".chose_subject_div span").click(function() {
				if ($(this).hasClass("choose_subject")) {
					$(this).removeClass("choose_subject");
				} else {
					$(this).addClass("choose_subject");
				}

			});

			//老师提交订单前的验证
			//验证手机号
			var phoneIsRight = 0;
			$("#login_phone").change(function() {

				var re = /^1[34578]{1}\d{9}$/
				if (!re.test($(this).val())) {
					$(this).parent().addClass("redMustAdd");
					phoneIsRight = 0;
					return false;
				} else {
					$(this).parent().removeClass("redMustAdd");
					phoneIsRight = 1;

				}

			})
			//验证密码
			var pwdIsRight = 0;
			$("#login_pwd").change(function() {
				if ($(this).val().length < 6) {
					$(this).parent().addClass("redMustAdd");
					pwdIsRight = 0;
					return false;

				}else{
					$(this).parent().removeClass("redMustAdd");
					pwdIsRight = 1;
				}

			})
			//科目验证
			var subjectIsRight=0;
			$(".chose_subject ").click(function(){
				if($(this).parent().find(".choose_subject").size()==0){
					$(this).parent().parent().addClass("redMustAdd");
				subjectIsRight = 0;
					return false;
				
				
				}else{
					$(this).parent().parent().removeClass("redMustAdd");
					subjectIsRight = 1;
				}
			
			
			
			
			})




			//老师提交订单
			$("#order_person_submit")
					.click(
							function() {
							var typeNow = $.cookie("type");
								if (typeNow == "null" || typeNow == 0) {
									$("#loginNow_div").show();
									return false;
								}
								if (typeNow == 1) {
									alert("学生约学生，你这是早恋你知道吗？")
									$(".student_introduce_banner_center_line03").fadeOut();
									return false;
								}
								if (typeNow == 3) {
									alert("您是管理员，就不要闹啦！")
									$(".student_introduce_banner_center_line03").fadeOut();
									return false;
								}
// 							判断该输入的内容是否输入
								if(phoneIsRight==0){
									$(this).parent().find("#phoneLabel").addClass("redMustAdd");
									return false;
								}
								if(pwdIsRight==0){
									$(this).parent().find("#pwdLabel").addClass("redMustAdd");
									return false;
								}
								if(subjectIsRight==0){
									$(this).parent().find("#subjectLabel").addClass("redMustAdd");
									return false;
								}

								
								var studentId = "${studentInfos.studentId}";
								var teacherId = "${id}";
								var gradeName = $("#student_stutype").val();
								//找到所选科目
								var subjects = new Array();
								var i = 0;
								$("#chose_subject_div").find(".choose_subject")
										.each(
												function() {
													subjects[i] = $(this).attr(
															"subjectId");
													i++;
												})
								// 			找到老师姓名和电话号码并加密
								var login_phone = $(this).parent().parent()
										.find("#login_phone").val();
								var login_pwd = $(this).parent().parent().find(
										"#login_pwd").val();
								login_pwd = login_phone + login_pwd
										+ login_phone;
								login_pwd = $.md5(login_pwd);
								var json = {
									"login_phone" : login_phone,
									"login_pwd" : login_pwd,
									"studentId" : studentId,
									"teacherId" : teacherId,
									"subjects" : subjects,
									"gradeName" : gradeName
								};
								//ajax
								$
										.ajax({
											type : 'post',
											url : '/GDZjiajiaowang/NewOrderByTeacherServlet',
											data : json,
											datatype : 'json',
											traditional : true,
											contentType : "application/x-www-form-urlencoded; charset =utf-8",
											success : function(id) {
												alert(id);
												if(id=="-1"){
													alert("今天已经预约过啦！客服正在帮您安排！")
													return false;
												}
												if (id != 0) {
													alert("发布订单成功");
// 													为新订单赋值
													$("#newOrderByTeacherOrderId").text(id);
													$("#newOrderByTeacherSubject").text($("#chose_subject_div").find(".choose_subject").text());
													$("#newOrderByTeacherGradeName").text($("#student_stutype").text());
													$("#newOrderByTeacherStudentName").text($(".student_introduce_banner_name").text());
													$("#newOrderByTeacherTeacherName").text($("#uNameNow").text());
													$("#newOrderByTeacherPhone").text(login_phone);
													
													
													$(".teacher_order_show")
															.fadeIn();
												}else{
													alert("手机号码或者密码错误！")
												}
											}
										})
							})
		})
	</script>
	<!--
            	作者：GGVVR
            	时间：2017-10-25
            	描述：下单成功
            -->
	<%@include file="/source/page/parts/teacherOrder.jsp"%>

</body>
</html>
